//
// begin license header
//
// This file is part of Pixy CMUcam5 or "Pixy" for short
//
// All Pixy source code is provided under the terms of the
// GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
// Those wishing to use Pixy source code, software and/or
// technologies under different licensing terms should contact us at
// cmucam@cs.cmu.edu. Such licensing terms are available for
// all portions of the Pixy codebase presented here.
//
// end license header
//

#ifndef CAMERA_H
#define CAMERA_H

#include "chirp.hpp"
#include "sccb.h"
#include "pixytypes.h"
#include <cameravals.h>


int cam_init();

int32_t cam_setMode(const uint8_t &mode);
uint32_t cam_getMode();

int32_t cam_setAWB(const uint8_t &awb);
uint32_t cam_getAWB();
							   
int32_t cam_setWBV(const uint32_t &wbv);
uint32_t cam_getWBV();

int32_t cam_setAEC(const uint8_t &aec);
uint32_t cam_getAEC();

int32_t cam_setECV(const uint32_t &ecv);
uint32_t cam_getECV();

int32_t cam_setBrightness(const uint8_t &brightness);
uint32_t cam_getBrightness();

int32_t cam_setLightMode(const uint8_t &mode);
uint32_t cam_getLightMode();

int cam_testPattern(const uint8_t &enable);

int32_t cam_getFrameChirp(const uint8_t &type, const uint16_t &xOffset, const uint16_t &yOffset, const uint16_t &xWidth, const uint16_t &yWidth, Chirp *chirp);
int32_t cam_getFrameChirpFlags(const uint8_t &type, const uint16_t &xOffset, const uint16_t &yOffset, const uint16_t &xWidth, const uint16_t &yWidth, Chirp *chirp, uint8_t renderFlags=RENDER_FLAG_FLUSH);
int32_t cam_getFrame(uint8_t *memory, uint32_t memSize, uint8_t type, uint16_t xOffset, uint16_t yOffset, uint16_t xWidth, uint16_t yWidth);
int32_t cam_setRegister(const uint8_t &reg, const uint8_t &value);
int32_t cam_getRegister(const uint8_t &reg);


void cam_loadParams();

extern CSccb *g_sccb;
extern Frame8 g_rawFrame;

/* default register values for OV9715
0x0=0x0
0x1=0x40
0x2=0x40
0x3=0x2
0x4=0x8
0x5=0x40
0x6=0x0
0x7=0x0
0x8=0x0
0x9=0x0
0xa=0x97
0xb=0x11
0xc=0x0
0xd=0x1
0xe=0x40
0xf=0x0
0x10=0x9a
0x11=0x0
0x12=0x0
0x13=0x85
0x14=0x40
0x15=0x0
0x16=0x3
0x17=0x26
0x18=0xa2
0x19=0x1
0x1a=0xc8
0x1b=0x81
0x1c=0x7f
0x1d=0xa2
0x1e=0x0
0x1f=0x0
0x20=0x0
0x21=0x3
0x22=0x0
0x23=0x0
0x24=0x60
0x25=0x55
0x26=0xd2
0x27=0x0
0x28=0x0
0x29=0x0
0x2a=0x9b
0x2b=0x6
0x2c=0x50
0x2d=0x0
0x2e=0x0
0x2f=0x10
0x30=0x8
0x31=0x20
0x32=0x1
0x33=0x0
0x34=0x0
0x35=0x0
0x36=0x0
0x37=0x6
0x38=0x10
0x39=0x28
0x3a=0x9
0x3b=0x0
0x3c=0x0
0x3d=0x3c
0x3e=0x3
0x3f=0x0
0x40=0x0
0x41=0x82
0x42=0x14
0x43=0xc0
0x44=0xca
0x45=0xca
0x46=0xc3
0x47=0xc4
0x48=0x55
0x49=0xcf
0x4a=0x0
0x4b=0x36
0x4c=0x13
0x4d=0x10
0x4e=0x55
0x4f=0x55
0x50=0x55
0x51=0x55
0x52=0x10
0x53=0x42
0x54=0x30
0x55=0xff
0x56=0x1f
0x57=0x0
0x58=0xc8
0x59=0xa0
0x5a=0x57
0x5b=0x20
0x5c=0x59
0x5d=0x0
0x5e=0xa
0x5f=0x0
0x60=0xd
0x61=0x82
0x62=0x2
0x63=0x0
0x64=0x33
0x65=0x1a
0x66=0xc
0x67=0x2
0x68=0x7
0x69=0x4
0x6a=0x2
0x6b=0x0
0x6c=0x1
0x6d=0x82
0x6e=0xc0
0x6f=0xe0
0x70=0x2
0x71=0x0
0x72=0x60
0x73=0xb0
0x74=0x40
0x75=0xe0
0x76=0xc0
0x77=0xc0
0x78=0xff
0x79=0xff
0x7a=0x10
0x7b=0x0
0x7c=0x0
0x7d=0x0
0x7e=0x0
0x7f=0x0
0x80=0x0
0x81=0x0
0x82=0x0
0x83=0x0
0x84=0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